<template>
    <div class="home-container">
      <div class="nav-group">
        <div class="nav-header">
          <img class="app-logo" src="../../assets/logo.png" alt="logo" />
        </div>
        <div class="nav-content">
          <div class="nav-button">
            <button class="new-button">
              <div class="button-wrapper">
                <div id="plus-icon" class="plus-icon">
                  <svg
                    xmlns="http://www.w3.org/2000/svg"
                    class="svg-icon icon"
                    viewBox="0 0 14 14"
                    aria-hidden="true"
                    width="14"
                    height="14"
                  >
                    <path
                      d="M7 0a1.5 1.5 0 0 1 1.5 1.5v4h4a1.5 1.5 0 0 1 0 3h-4v4a1.5 1.5 0 0 1-3 0v-4h-4a1.5 1.5 0 0 1 0-3h4v-4A1.5 1.5 0 0 1 7 0z"
                      fill="#FFF"
                      fill-rule="evenodd"
                    ></path>
                  </svg>
                </div>
                <div class="build-button">新建</div>
              </div>
            </button>
  
            <button class="new-button" @click="setTheme">
              <div class="button-wrapper">
                <div id="plus-icon" class="plus-icon">
                  <svg
                    class="svg-icon icon"
                    viewBox="0 0 1024 1024"
                    xmlns="http://www.w3.org/2000/svg"
                    p-id="2448"
                    width="15"
                    height="15"
                  >
                    <path
                      d="M512 938.666667c235.648 0 426.666667-191.018667 426.666667-426.666667S747.648 85.333333 512 85.333333 85.333333 276.352 85.333333 512s191.018667 426.666667 426.666667 426.666667z m0-85.333334V170.666667a341.333333 341.333333 0 1 1 0 682.666666z"
                      p-id="2449"
                      fill="#fff"
                    ></path>
                  </svg>
                </div>
                <div class="build-button">主题</div>
              </div>
            </button>
          </div>
        </div>
      </div>
      <div class="main">
        <div class="main-left">
          <SearchInput />
  
          <div class="project">
            <div
              class="project-active"
              :style="{ top: `${projectIndex * 38}px` }"
            ></div>
            <div class="project-content">
              <div
                :class="['project-item', projectIndex == index ? 'active' : null]"
                v-for="(item, index) in project"
                :key="index"
                @click="handleProject(item, index)"
              >
                <span>{{ item.label }}</span>
              </div>
            </div>
          </div>
        </div>
        <div class="main-rigt">
          <div class="main-header">
            <div class="addvertising">
              <!-- <img src="https://alp.alicdn.com/1661309192868-2100-220.png" width="100%"> -->
            </div>
  
            <div class="tabs">
              <div class="tab-pane">
                <svg-icon class="svg-icon" icon="copy" />
                <span>复制</span>
              </div>
              <div class="tab-pane">
                <svg-icon class="svg-icon" icon="move" />
                <span>移动</span>
              </div>
            </div>
          </div>
          <div class="main-page">
            <div class="page-item" v-for="(item, index) in pageList" :key="index">
              <div class="page-item-info">暂无缩略图</div>
              <div class="page-hover">
                <div class="item-button" @click="viewPage(item)">预览</div>
                <div class="item-button" @click="editPage(item)">编辑</div>
                <div class="item-button">删除</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </template>
  
  <script>
  import SearchInput from "@/components/SearchInput";
  export default {
    components: {
      SearchInput,
    },
    data() {
      return {
        projectIndex: 0,
        project: [
          {
            label: "页面",
          },
          {
            label: "模板",
          },
        ],
        pageList: [
          {
            pageId: "PG1662434086938",
          },
        ],
      };
    },
    methods: {
      handleProject(item, index) {
        this.projectIndex = index;
      },
      setTheme() {
        this.$store.dispatch("theme/setTheme");
      },
      viewPage(item) {
        this.$router.push({
          name: "View",
          query: {
            pageId: item.pageId,
          },
        });
      },
      editPage(item) {
        const pageId = `PG${new Date().valueOf()}`;
        this.$router.push({
          name: "Design",
          query: {
            pageId: item.pageId,
          },
        });
      },
    },
  };
  </script>
  
  <style scoped lang="scss">
  .tabs {
    margin-top: 32px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    height: 36px;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
  
    .tab-pane {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      margin-right: 16px;
      height: 100%;
      font-size: 14px;
      color: var(--color);
      cursor: pointer;
  
      &:hover {
        color: var(--font-hover);
  
        .svg-icon {
          color: var(--font-hover);
        }
      }
    }
  }
  
  .main-left {
    width: 164px;
    height: 100%;
    padding: 0px 6px;
    border-right: 1px solid var(--border-color);
  
    .project {
      position: relative;
      width: 100%;
  
      .project-active {
        position: absolute;
        top: 0;
        z-index: 1;
        width: 100%;
        height: 38px;
        border-radius: 4px;
        background-color: var(--background-hover);
        transition: all 0.28s;
      }
    }
  
    .project-content {
      position: absolute;
      width: 100%;
      top: 0;
      color: var(--font-color);
      z-index: 2;
  
      .active {
        color: var(--font-hover);
      }
  
      .project-item {
        width: 100%;
        height: 38px;
        cursor: pointer;
        display: flex;
        justify-content: center;
        align-items: center;
      }
    }
  }
  
  .home-container {
    width: 100%;
    min-width: 726px;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
  
    .nav-group {
      width: 80px;
      height: 100%;
      overflow-y: auto;
      overflow-x: hidden;
      background: var(--background);
      box-shadow: rgb(0 0 0 / 5%) 9px 0px 28px 0px;
      border-right: 1px solid var(--border-color);
  
      .nav-header {
        width: 100%;
        height: 64px;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 14px;
        font-weight: bold;
        color: var(--font-color);
        border-bottom: 1px solid var(--border-color);
  
        .app-logo {
          width: 46px;
          height: 46px;
        }
      }
  
      .nav-content {
        width: 100%;
        height: calc(100% - 64px);
        padding: 6px;
      }
    }
  
    .main {
      flex: 1;
      height: 100%;
      display: flex;
  
      .main-rigt {
        flex: 1;
        min-width: 486px;
        height: 100%;
        display: flex;
        flex-direction: column;
  
        .main-header {
          width: 100%;
          // height: 68px;
          margin-bottom: 16px;
  
          .addvertising {
            width: 100%;
  
            & img {
              width: 100%;
            }
          }
        }
  
        .main-page {
          width: 100%;
          flex: 1;
          padding: 0 16px;
          overflow-y: auto;
          overflow-x: hidden;
          display: grid;
          justify-content: space-between;
          grid-template-columns: repeat(auto-fill, 200px);
          gap: 16px;
          grid-template-rows: repeat(auto-fill, 160px);
  
          &::-webkit-scrollbar {
            display: none;
          }
        }
      }
    }
  }
  
  .new-button {
    margin: 0px;
    padding: 0px;
    appearance: none;
    background: none;
    border: 0px;
    outline: 0px;
  
    .button-wrapper {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      height: 66px;
      width: 64px;
      margin: 0px auto;
      border-radius: 4px;
      position: relative;
  
      .plus-icon {
        width: 30px;
        height: 30px;
        background: var(--theme-color);
        box-shadow: rgb(236 73 84 / 25%) 0px 4px 6px 0px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
      }
  
      .build-button {
        margin-top: 4px;
        font-size: 12px;
        color: var(--font-color);
      }
    }
  }
  
  .page-item {
    position: relative;
    width: 200px;
    height: 160px;
    margin-bottom: 8px;
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--page-background);
    box-shadow: rgb(0 0 0 / 8%) 0px 2px 4px 0px;
  
    &:hover {
      .page-hover {
        top: 0px;
        opacity: 1;
      }
  
      .page-item-info {
        transform: translateY(-100%);
        opacity: 0;
      }
    }
  
    .page-item-info {
      position: absolute;
      top: 0;
      width: 200px;
      height: 160px;
      display: flex;
      justify-content: space-around;
      align-items: center;
      color: var(--font-color);
      transition: all 0.28s ease;
    }
  
    .page-hover {
      position: absolute;
      top: 160px;
      width: 100%;
      height: 100%;
      background-color: var(--page-background);
      color: var(--font-color);
      opacity: 0;
      transition: all 0.28s ease;
      display: flex;
      justify-content: space-around;
      align-items: center;
      z-index: 24;
  
      .item-button {
        cursor: pointer;
        display: flex;
        justify-content: center;
        align-items: center;
        flex: 1;
        height: 100%;
  
        &:hover {
          color: var(--font-hover);
          background: var(--background-hover);
        }
      }
    }
  }
  
  .svg-icon {
    color: var(--font-color);
    margin-right: 4px;
  }
  </style>
  